#include <iostream>
#include <ctime>
#include <cstdlib>
#include "HumanPlayer.h"

using namespace std;

HumanPlayer::HumanPlayer(string name) :
		Player(name) {
}

Cell* HumanPlayer::next() {
	vector<Cell*> cells = *mBoard->findPutableCells(mColor);
	if (cells.empty()) {
		return NULL;
	} else if (cells.size() == 1) {
		return cells[0];
	}

	do {
		int line;
		cout << "input cell : ";
		std::cin >> line;

		int x = line / 10 - 1;
		int y = line % 10 - 1;

		vector<Cell*>::iterator it = cells.begin();
		while (it != cells.end()) {
			Cell* cell = (*it);
			if (cell->getX() == x && cell->getY() == y) {
				return cell;
			}
			++it;
		}
		cerr << "not match.";
	} while (true);
}
